'''
Created on Apr 7, 2011

@author: Tyler
'''
import orange

if __name__ == '__main__':
    pass
"""
data = orange.ExampleTable("../test")

print "Attributes:",
for i in data.domain.attributes:
    print i.name,
print
print "Class:", data.domain.classVar.name

print "First 5 data items:"
for i in range(5):
    print data[i]
    
# obtain class distribution
c = [0] * len(data.domain.classVar.values)
for e in data:
    c[int(e.getclass())] += 1
print "Instances: ", len(data), "total",
for i in range(len(data.domain.classVar.values)):
    print ",", c[i], "with class", data.domain.classVar.values[i],
print

dist = orange.DomainDistributions(data)
print "Average values and mean square errors:"
for i in range(len(data.domain.attributes)):
    if data.domain.attributes[i].varType == orange.VarTypes.Continuous:
        print "%s, mean=%5.10f +- %5.10f" % \
            (data.domain.attributes[i].name, dist[i].average(), dist[i].error())
"""
import orngTest,orngStat

train_data = orange.ExampleTable("../train")


knn = knn = orange.kNNLearner(k=4)
learners = [knn]

results = orngTest.crossValidation(learners, train_data, folds=5)

# output the results
print "Learner  CA     IS     Brier    AUC"
for i in range(len(learners)):
    print "%-8s %5.3f  %5.3f  %5.3f  %5.3f" % (learners[i].name, \
        orngStat.CA(results)[i], orngStat.IS(results)[i],
        orngStat.BrierScore(results)[i], orngStat.AUC(results)[i])